import http from '../index'

// 分页获取商家
export const getStores = ({ ascended = null, current = null, size = null, sortFieldName = null, status = null, approval = null, personName = null, personPhone = null, storeName = null }) => {
    return http.get("stores", { ascended, current, size, sortFieldName, status, approval, personName, personPhone, storeName })
}

// 根据sid获取商家
export const getStoreDetail = ({ sid }) => {
    return http.get("stores/" + sid)
}

// 根据用户sid获取商家信息
export const getStoreDetailByUserSid = ({ sid }) => {
    return http.get("stores/" + sid + '/user')
}

// 新增商家
export const addStore = ({ accountBank, accountBankNumber, accountName, accountNumber, businessImgUrl, personName, personNumber, personPhone, storeName, taxNumber, status = null }) => {
    return http.post("stores", { accountBank, accountBankNumber, accountName, accountNumber, businessImgUrl, personName, personNumber, personPhone, storeName, taxNumber, status })
}

// 修改商家
export const editStore = ({ sid, accountBank, accountBankNumber, accountName, accountNumber, businessImgUrl, personName, personNumber, personPhone, storeName, taxNumber, status = null }) => {
    return http.put("stores/" + sid, { accountBank, accountBankNumber, accountName, accountNumber, businessImgUrl, personName, personNumber, personPhone, storeName, taxNumber, status })
}

// 批量删除商家
export const delStores = ({ sidList }) => {
    return http.put("stores/delete", { sidList })
}

// 根据sid启用-停用商家
export const changeStoreStatus = ({ sid }) => {
    return http.put("stores/" + sid + '/status')
}

// 审核商家
export const approvalStore = ({ sid, approval, note = null }) => {
    return http.put("stores/" + sid + '/approval', { approval, note })
}

// 用户确认是否成为员工
export const joinStore = ({ storeSid, status }) => {
    return http.get("stores/" + storeSid + '/join-status/' + status)
}

// 商家邀请用户成为员工
export const inviteUserBecomeStore = ({ userPhone }) => {
    return http.get("stores/members/" + userPhone + '/invit')
}



